import { getUserByPositionApi } from "@/api/managementCenter/departmentPersonnel";
import { reactive } from "vue";

export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "公司名称",
    keyName: "companyName"
  },
  {
    type: "input",
    label: "客户简称",
    keyName: "shortName"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "业务",
    keyName: "bizId",
    optionsRequest: getUserByPositionApi,
    optReqParams: { position: "4", status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "跟单",
    keyName: "followId",
    optionsRequest: getUserByPositionApi,
    optReqParams: { position: "5", status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    options: []
  }),
  {
    type: "datetimerange",
    label: "开户时间",
    keyName: "createTime"
  }
];

// 列表
export const tableColumn: Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem> = [
  {
    field: "checkbox",
    type: "checkbox",
    minWidth: "50"
  },
  {
    field: "companyName",
    title: "公司名称",
    minWidth: "140"
  },
  {
    field: "shortName",
    title: "客户简称",
    minWidth: "120"
  },
  {
    field: "accountName",
    title: "登录账号",
    minWidth: "120"
  },
  {
    field: "bizName",
    title: "业务员",
    minWidth: "120"
  },
  {
    field: "followName",
    title: "跟单员",
    minWidth: "120"
  },
  {
    field: "finName",
    title: "财务",
    minWidth: "120"
  },
  {
    field: "accountPeriodName",
    title: "账期",
    minWidth: "120"
  },
  {
    field: "createName",
    title: "开户人",
    minWidth: "120"
  },
  {
    field: "createTime",
    title: "开户日期",
    minWidth: "135",
    formatter: "formatDate"
  },
  {
    field: "lastOrderTime",
    title: "最后走货时间",
    minWidth: "135",
    formatter: "formatDate"
  },
  {
    field: "companyUnit",
    title: "经营单位",
    minWidth: "135"
  },
  {
    field: "status",
    title: "状态",
    minWidth: "90",
    renderSlot: "status"
  },
  {
    field: "action",
    title: "操作",
    minWidth: "180",
    renderSlot: "action"
  }
];
